package com.lagou.service;

import com.lagou.pojo.Article;
import com.lagou.repository.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Autowired
    private ArticleRepository articleRepository;

    @Cacheable(value = "article")
    public Page<Article> getArticleList(int pageNo){
        Pageable pageable = PageRequest.of(pageNo,2);
        Page<Article> all = articleRepository.findAll(pageable);
        System.out.println(all);
        return all;
    }


}
